package com.qfedu.edu.seckill.searchservice.controller;

import com.qfedu.edu.seckill.po.Class;
import com.qfedu.edu.seckill.result.R;
import com.qfedu.edu.seckill.searchservice.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * @author xiaobobo
 * @title: SearchController
 * @projectName cd-java-2404-seckill-parent
 * @description: 搜索服务的控制器
 * @date 2025/2/5  14:06
 */
@RequestMapping("/searchservice/search")
@RestController
public class SearchController {

    @Autowired
    private SearchService searchService;

    /**
     * 分页查询数据(这里是从ES中去查询这个数据)
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GetMapping("/listByPage/{currentPage}/{pageSize}")
    public R listByPage(@PathVariable("currentPage") Integer currentPage,
                        @PathVariable("pageSize") Integer pageSize) throws IOException {
        List<Class> classList = searchService.listByPage(currentPage, pageSize);
        return R.ok().data("classList", classList);
    }


}
